package com.platform.modules.job.controller;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.common.utils.RestResponse;
import com.platform.modules.job.entity.ScheduleJobLogEntity;
import com.platform.modules.job.service.ScheduleJobLogService;

/**
 * 定时任务日志
 *
 * @author 肖亮
 */
@RestController
@RequestMapping("/sys/scheduleLog")
public class ScheduleJobLogController {
	@Autowired
	private ScheduleJobLogService scheduleJobLogService;

	/**
	 * 分页查询定时任务日志
	 *
	 * @param params
	 *            查询参数
	 * @return RestResponse
	 */
	@GetMapping("/list")
	@RequiresPermissions("sys:schedule:log")
	public RestResponse list(@RequestParam Map<String, Object> params) {
		Page page = scheduleJobLogService.queryPage(params);

		return RestResponse.success().put("page", page);
	}

	/**
	 * 根据主键查询详情
	 *
	 * @param logId
	 *            logId
	 * @return RestResponse
	 */
	@GetMapping("/info/{logId}")
	public RestResponse info(@PathVariable("logId") String logId) {
		ScheduleJobLogEntity log = scheduleJobLogService.getById(logId);

		return RestResponse.success().put("log", log);
	}
}
